
package bienvenido;

import java.awt.Color;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileWriter;
import java.util.Calendar;
import java.util.Vector;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;


public class BienvenidoView extends FrameView {
    
    public static int filaselec= -1;
    
    public static String fra1;
    
    public static String segmentaHistorial(String frase){
        int l=frase.length();
        String f=frase;
        if(l<60){
            fra1="";
            return f;
        }
        else{
            f="";
            for(int i=0;i<60;i++){
                f=f+frase.charAt(i);
            }
            int j=59;
            char c=frase.charAt(j);
            while(c!=' '){
                j=j-1;
                c=frase.charAt(j);
            }
            f=f.substring(0,j);
            fra1=frase.substring(j+1, l);
            return f;
        }
    }
    
    public BienvenidoView(SingleFrameApplication app) {
        super(app);
        initComponents();
        Infoenvio.setVisible(false);
        Infoenvio2.setVisible(false);
        BarraProgreso.setVisible(false);
        Encabezado_actual_text.setEditable(false);
    
        historial_actualizar.doClick();
        usuarios_actualizar.doClick();

        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");

        ImageIcon actualizarHistorial = new ImageIcon(BienvenidoView.class.getResource("resources/actualizar.png"));
        historial_actualizar.setIcon(actualizarHistorial);

        ImageIcon actualizarUsuario = new ImageIcon(BienvenidoView.class.getResource("resources/actualizar.png"));
        usuarios_actualizar.setIcon(actualizarUsuario);
        
        boton_iniciar_envio.setText("Iniciar envio");
        ImageIcon off = new ImageIcon(BienvenidoView.class.getResource("resources/off.png"));
        ImageIcon on = new ImageIcon(BienvenidoView.class.getResource("resources/on.png"));
        boton_iniciar_envio.setIcon(on);

        historial_contenidomensaje.setEditable(false);
        usuarios_lista.setDragEnabled(false);

        TestConnection conex = new TestConnection();
        
        String encabezadoactual= conex.ultimoEncabezado();
        if (encabezadoactual.equals("")){
            encabezadoactual="No existe encabezado";
        }
        Encabezado_actual_text.setText(encabezadoactual);
        
        int n1 = conex.getconexExitosas();
        int n2 = conex.getconexRechazadas();
        historial_exitosas.setText(""+n1);
        historial_rechazadas.setText(""+n2);
        String d1 = conex.getDiaAltaFrecuencia(); 
        String d2 = conex.getDiaBajaFrecuencia();
        historial_diarecibimiento.setText(d1);
        historial_diarechazo.setText(d2);
     

        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
       
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
       
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
       
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = BienvenidoApp.getApplication().getMainFrame();
            aboutBox = new BienvenidoAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        BienvenidoApp.getApplication().show(aboutBox);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        nuevo_asunto = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        nuevo_contenido = new javax.swing.JTextArea();
        jLabel2 = new javax.swing.JLabel();
        nuevo_activarencabezado = new javax.swing.JCheckBox();
        jPanel4 = new javax.swing.JPanel();
        boton_iniciar_envio = new javax.swing.JButton();
        nuevo_confirmar = new javax.swing.JButton();
        nuevo_limpiar = new javax.swing.JButton();
        About1 = new javax.swing.JButton();
        contador = new javax.swing.JLabel();
        BarraProgreso = new javax.swing.JProgressBar();
        Infoenvio = new javax.swing.JLabel();
        Infoenvio2 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        Encabezado_actual_text = new javax.swing.JTextArea();
        encabezadoact_label = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        historial_exitosas = new javax.swing.JLabel();
        historial_rechazadas = new javax.swing.JLabel();
        historial_diarecibimiento = new javax.swing.JLabel();
        historial_diarechazo = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        historial_lista = new javax.swing.JList();
        jLabel11 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        historial_contenidomensaje = new javax.swing.JTextArea();
        jLabel12 = new javax.swing.JLabel();
        historial_actualizar = new javax.swing.JButton();
        About2 = new javax.swing.JButton();
        boton_eliminarMsje = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        usuarios_lista = new javax.swing.JTable();
        historial_bloquear = new javax.swing.JButton();
        usuarios_actualizar = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        About4 = new javax.swing.JButton();

        mainPanel.setMinimumSize(new java.awt.Dimension(100, 100));
        mainPanel.setName("mainPanel"); // NOI18N

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(bienvenido.BienvenidoApp.class).getContext().getResourceMap(BienvenidoView.class);
        jPanel1.setForeground(resourceMap.getColor("jPanel1.foreground")); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        nuevo_asunto.setFont(resourceMap.getFont("nuevo_asunto.font")); // NOI18N
        nuevo_asunto.setText(resourceMap.getString("nuevo_asunto.text")); // NOI18N
        nuevo_asunto.setName("nuevo_asunto"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        nuevo_contenido.setColumns(20);
        nuevo_contenido.setFont(resourceMap.getFont("nuevo_contenido.font")); // NOI18N
        nuevo_contenido.setRows(5);
        nuevo_contenido.setName("nuevo_contenido"); // NOI18N
        nuevo_contenido.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                nuevo_contenidoKeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(nuevo_contenido);

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        nuevo_activarencabezado.setText(resourceMap.getString("nuevo_activarencabezado.text")); // NOI18N
        nuevo_activarencabezado.setName("nuevo_activarencabezado"); // NOI18N
        nuevo_activarencabezado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nuevo_activarencabezadoActionPerformed(evt);
            }
        });

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel4.setName("jPanel4"); // NOI18N

        boton_iniciar_envio.setBackground(resourceMap.getColor("boton_iniciar_envio.background")); // NOI18N
        boton_iniciar_envio.setForeground(resourceMap.getColor("boton_iniciar_envio.foreground")); // NOI18N
        boton_iniciar_envio.setText(resourceMap.getString("boton_iniciar_envio.text")); // NOI18N
        boton_iniciar_envio.setBorderPainted(false);
        boton_iniciar_envio.setName("boton_iniciar_envio"); // NOI18N
        boton_iniciar_envio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_iniciar_envioActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(boton_iniciar_envio, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(boton_iniciar_envio, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
                .addContainerGap())
        );

        nuevo_confirmar.setText(resourceMap.getString("nuevo_confirmar.text")); // NOI18N
        nuevo_confirmar.setName("nuevo_confirmar"); // NOI18N
        nuevo_confirmar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nuevo_confirmarActionPerformed(evt);
            }
        });

        nuevo_limpiar.setText(resourceMap.getString("nuevo_limpiar.text")); // NOI18N
        nuevo_limpiar.setName("nuevo_limpiar"); // NOI18N
        nuevo_limpiar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                nuevo_limpiarMouseReleased(evt);
            }
        });

        About1.setText(resourceMap.getString("About1.text")); // NOI18N
        About1.setName("About1"); // NOI18N
        About1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                About1MouseReleased(evt);
            }
        });
        About1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                About1ActionPerformed(evt);
            }
        });

        contador.setText(resourceMap.getString("contador.text")); // NOI18N
        contador.setName("contador"); // NOI18N

        BarraProgreso.setName("BarraProgreso"); // NOI18N

        Infoenvio.setText(resourceMap.getString("Infoenvio.text")); // NOI18N
        Infoenvio.setName("Infoenvio"); // NOI18N

        Infoenvio2.setText(resourceMap.getString("Infoenvio2.text")); // NOI18N
        Infoenvio2.setName("Infoenvio2"); // NOI18N

        jScrollPane5.setName("jScrollPane5"); // NOI18N

        Encabezado_actual_text.setColumns(20);
        Encabezado_actual_text.setRows(5);
        Encabezado_actual_text.setName("Encabezado_actual_text"); // NOI18N
        jScrollPane5.setViewportView(Encabezado_actual_text);

        encabezadoact_label.setText(resourceMap.getString("encabezadoact_label.text")); // NOI18N
        encabezadoact_label.setName("encabezadoact_label"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(58, 58, 58)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(nuevo_activarencabezado, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 113, Short.MAX_VALUE)
                        .addComponent(contador, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 441, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(Infoenvio)
                            .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(BarraProgreso, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addComponent(nuevo_confirmar, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(30, 30, 30)
                                .addComponent(nuevo_limpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(Infoenvio2, javax.swing.GroupLayout.Alignment.LEADING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(nuevo_asunto, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addGap(39, 39, 39)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(encabezadoact_label)
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(45, 45, 45))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(About1)
                .addContainerGap(466, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(encabezadoact_label))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(nuevo_asunto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(nuevo_activarencabezado)
                    .addComponent(contador, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nuevo_confirmar, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(nuevo_limpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(About1))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(BarraProgreso, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(Infoenvio)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Infoenvio2)))
                .addContainerGap())
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

        jPanel2.setName("jPanel2"); // NOI18N

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel5.setName("jPanel5"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        historial_exitosas.setText(resourceMap.getString("historial_exitosas.text")); // NOI18N
        historial_exitosas.setName("historial_exitosas"); // NOI18N

        historial_rechazadas.setText(resourceMap.getString("historial_rechazadas.text")); // NOI18N
        historial_rechazadas.setName("historial_rechazadas"); // NOI18N

        historial_diarecibimiento.setText(resourceMap.getString("historial_diarecibimiento.text")); // NOI18N
        historial_diarecibimiento.setName("historial_diarecibimiento"); // NOI18N

        historial_diarechazo.setText(resourceMap.getString("historial_diarechazo.text")); // NOI18N
        historial_diarechazo.setName("historial_diarechazo"); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(historial_exitosas))
                    .addComponent(jLabel8))
                .addGap(78, 78, 78)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(historial_diarecibimiento))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(historial_diarechazo)))
                .addContainerGap(56, Short.MAX_VALUE))
            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup()
                    .addGap(140, 140, 140)
                    .addComponent(historial_rechazadas)
                    .addContainerGap(278, Short.MAX_VALUE)))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jLabel9)
                    .addComponent(historial_exitosas)
                    .addComponent(historial_diarecibimiento))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel10)
                    .addComponent(historial_diarechazo))
                .addContainerGap(24, Short.MAX_VALUE))
            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup()
                    .addGap(35, 35, 35)
                    .addComponent(historial_rechazadas)
                    .addContainerGap(25, Short.MAX_VALUE)))
        );

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        historial_lista.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        historial_lista.setName("historial_lista"); // NOI18N
        historial_lista.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                historial_listaValueChanged(evt);
            }
        });
        jScrollPane2.setViewportView(historial_lista);

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        historial_contenidomensaje.setColumns(20);
        historial_contenidomensaje.setEditable(false);
        historial_contenidomensaje.setFont(resourceMap.getFont("historial_contenidomensaje.font")); // NOI18N
        historial_contenidomensaje.setRows(5);
        historial_contenidomensaje.setDisabledTextColor(resourceMap.getColor("historial_contenidomensaje.disabledTextColor")); // NOI18N
        historial_contenidomensaje.setEnabled(false);
        historial_contenidomensaje.setName("historial_contenidomensaje"); // NOI18N
        jScrollPane3.setViewportView(historial_contenidomensaje);

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        historial_actualizar.setText(resourceMap.getString("historial_actualizar.text")); // NOI18N
        historial_actualizar.setName("historial_actualizar"); // NOI18N
        historial_actualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                historial_actualizarActionPerformed(evt);
            }
        });

        About2.setText(resourceMap.getString("About2.text")); // NOI18N
        About2.setName("About2"); // NOI18N
        About2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                About2MouseReleased(evt);
            }
        });
        About2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                About2ActionPerformed(evt);
            }
        });

        boton_eliminarMsje.setText(resourceMap.getString("boton_eliminarMsje.text")); // NOI18N
        boton_eliminarMsje.setName("boton_eliminarMsje"); // NOI18N
        boton_eliminarMsje.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_eliminarMsjeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addContainerGap(107, Short.MAX_VALUE)
                                .addComponent(jLabel11)
                                .addGap(158, 158, 158))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(44, 44, 44)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(66, 66, 66)
                                .addComponent(jLabel12))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(54, 54, 54)
                                .addComponent(boton_eliminarMsje, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(30, 30, 30))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(historial_actualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(About2)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(historial_actualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12))
                .addGap(2, 2, 2)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(boton_eliminarMsje, javax.swing.GroupLayout.DEFAULT_SIZE, 42, Short.MAX_VALUE)))
                .addGap(18, 18, 18)
                .addComponent(About2)
                .addGap(102, 102, 102))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel2.TabConstraints.tabTitle"), jPanel2); // NOI18N

        jPanel3.setName("jPanel3"); // NOI18N

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        usuarios_lista.setAutoCreateRowSorter(true);
        usuarios_lista.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        usuarios_lista.setName("usuarios_lista"); // NOI18N
        usuarios_lista.getTableHeader().setReorderingAllowed(false);
        usuarios_lista.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                usuarios_listaMouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(usuarios_lista);

        historial_bloquear.setText(resourceMap.getString("historial_bloquear.text")); // NOI18N
        historial_bloquear.setName("historial_bloquear"); // NOI18N
        historial_bloquear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                historial_bloquearActionPerformed(evt);
            }
        });

        usuarios_actualizar.setName("usuarios_actualizar"); // NOI18N
        usuarios_actualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                usuarios_actualizarActionPerformed(evt);
            }
        });

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        About4.setText(resourceMap.getString("About4.text")); // NOI18N
        About4.setName("About4"); // NOI18N
        About4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                About4MouseReleased(evt);
            }
        });
        About4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                About4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 401, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(28, 28, 28)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(usuarios_actualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(10, 10, 10))
                                    .addComponent(historial_bloquear, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel3)))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(About4)))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addComponent(usuarios_actualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(31, 31, 31)
                        .addComponent(jLabel3)
                        .addGap(1, 1, 1)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(historial_bloquear, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(23, 23, 23)
                .addComponent(About4)
                .addGap(34, 34, 34))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 576, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE)
        );

        setComponent(mainPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void nuevo_activarencabezadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nuevo_activarencabezadoActionPerformed
        if(nuevo_activarencabezado.isSelected()){
            ClienteOBEX.activar_encabezado=true;
            String aux = nuevo_contenido.getText();
            contador.setForeground(Color.black);
            int caracteres = 75 - aux.length();
            if(caracteres<0){
                contador.setForeground(Color.red);
            }else{
                contador.setForeground(Color.black);
            }
            contador.setText(""+caracteres);
            nuevo_asunto.setEnabled(false);
        }else{
            ClienteOBEX.activar_encabezado=false;
            String aux = nuevo_contenido.getText();
            nuevo_asunto.setEnabled(true);
            contador.setForeground(Color.black);
            int caracteres = 200 - aux.length();
            if(caracteres<0){
                contador.setForeground(Color.red);
            }else{
                contador.setForeground(Color.black);
            }
            contador.setText(""+caracteres);
        }
    }//GEN-LAST:event_nuevo_activarencabezadoActionPerformed

    private void nuevo_confirmarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nuevo_confirmarActionPerformed
        String mensaje;
        String asunto;
        asunto=nuevo_asunto.getText();
        mensaje= nuevo_contenido.getText()+" ";
        //mensaje= nuevo_contenido.getText();
        boolean bool = false;
        Calendar calendario = Calendar.getInstance();
        int dia = calendario.get(Calendar.DAY_OF_MONTH);
        int mes = calendario.get(Calendar.MONTH)+1;
        int año = calendario.get(Calendar.YEAR);
        String fecha = dia+"-"+mes+"-"+año;
        TestConnection aux = new TestConnection();
        aux.habilitaUsuario();//aqui metodo de habilitar usuario
        if (ClienteOBEX.activar_encabezado){
            if (mensaje.equals(" ")==false){
                    if(mensaje.length()<=75){
                        String mensajeOf = "";
                        for(int i=0;i<mensaje.length();i++){
                            if(mensaje.charAt(i)==' ' && i<28){
                                bool = true;
                            }
                            if(mensaje.charAt(i)=='\n'){
                                mensajeOf = mensajeOf + " ";
                            }else{
                                mensajeOf = mensajeOf + mensaje.charAt(i);
                            }
                        }
                        if(bool){
                            int showConfirmDialog = JOptionPane.showConfirmDialog(null,"¿Está seguro que desea guardar el siguiente encabezado?\n"+mensajeOf, "Consulta", JOptionPane.YES_NO_OPTION);
                            if(JOptionPane.YES_OPTION == showConfirmDialog){
                                String encabezado = nuevo_contenido.getText()+" ";
                                Administrador a = Login.admi;
                                aux.agregaMensaje("","",encabezado,a,fecha);
                                nuevo_contenido.setText("");
                                contador.setForeground(Color.black);
                                int large = 75;
                                contador.setText(""+large);
                                Encabezado_actual_text.setText(encabezado);
                            }
                        }else{
                            JOptionPane.showMessageDialog(null,"El encabezado consta de una palabra muy extensa para ser codificada en el mensaje.","Advertencia",JOptionPane.INFORMATION_MESSAGE);
                        }
                }else{
                            JOptionPane.showMessageDialog(null,"Verificar largo de encabezado (Máximo: 75 caracteres)","Advertencia",JOptionPane.INFORMATION_MESSAGE);    
                        }
            }else{
                JOptionPane.showMessageDialog(null,"Verifique Contenido del Encabezado","Advertencia",JOptionPane.INFORMATION_MESSAGE);
            }
        }else{
            if (mensaje.equals(" ")==false && asunto.equals("")==false){
                if (mensaje.length()<=200){
                    boolean muestra = false;
                    String mensajeOf = "";
                    for(int i=0;i<mensaje.length();i++){
                        if(mensaje.charAt(i)==' ' && i<28){
                            muestra = true;
                        }
                        if(mensaje.charAt(i)=='\n'){
                            mensajeOf = mensajeOf + " ";
                        }else{
                            mensajeOf = mensajeOf + mensaje.charAt(i);
                        }
                    }
                    if(!muestra){
                        JOptionPane.showMessageDialog(null,"El mensaje consta de una palabra muy extensa para ser codificada en el mensaje.","Advertencia",JOptionPane.INFORMATION_MESSAGE);
                    }else{
                        int showConfirmDialog = JOptionPane.showConfirmDialog(null,"¿Está seguro que desea guardar el siguiente mensaje?\n\n"+"Asunto: "+asunto+"\n\n"+"Contenido:\n"+mensajeOf+"\n", "Consulta", JOptionPane.YES_NO_OPTION);
                        if(JOptionPane.YES_OPTION == showConfirmDialog){
                            asunto = nuevo_asunto.getText();
                            mensaje= mensajeOf;
                            Administrador a = Login.admi;
                            aux.agregaMensaje(asunto,mensaje,"",a,fecha);
                            nuevo_asunto.setText("");
                            nuevo_contenido.setText("");
                            contador.setForeground(Color.black);
                            int large = 200;
                            contador.setText(""+large);
                        }
                    }
                }else{
                    JOptionPane.showMessageDialog(null,"Verificar largo del mensaje (Máximo: 200 caracteres)","Advertencia",JOptionPane.INFORMATION_MESSAGE);
                }
            }else{
                JOptionPane.showMessageDialog(null,"Verificar asunto y/o mensaje","Advertencia",JOptionPane.INFORMATION_MESSAGE);
            }
        }
    }//GEN-LAST:event_nuevo_confirmarActionPerformed

    private void nuevo_limpiarMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nuevo_limpiarMouseReleased
        nuevo_asunto.setText("");
        nuevo_contenido.setText("");
        if(ClienteOBEX.activar_encabezado){
            contador.setText("75");
        }else{
            contador.setText("200");
        }
    }//GEN-LAST:event_nuevo_limpiarMouseReleased

    private void About1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_About1MouseReleased
        showAboutBox();
    }//GEN-LAST:event_About1MouseReleased

    private void About2MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_About2MouseReleased
        showAboutBox();
    }//GEN-LAST:event_About2MouseReleased

    private void boton_iniciar_envioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_iniciar_envioActionPerformed
        ImageIcon off = new ImageIcon(BienvenidoView.class.getResource("resources/off.png"));
        ImageIcon on = new ImageIcon(BienvenidoView.class.getResource("resources/on.png"));
        if (ClienteOBEX.activar_envio){
            ClienteOBEX.activar_envio=false;
            BarraProgreso.setVisible(false);
            Infoenvio.setVisible(false);
            Infoenvio2.setVisible(false);
            boton_iniciar_envio.setText("Iniciar envio");
            boton_iniciar_envio.setIcon(on);
            boton_iniciar_envio.setBackground(Color.green);
            nuevo_confirmar.setEnabled(true);
        }else{
            
            ClienteOBEX.activar_envio=true;
            BarraProgreso.setIndeterminate(true);
            BarraProgreso.setVisible(true);
            boton_iniciar_envio.setText("Finalizar envio");
            boton_iniciar_envio.setIcon(off);
            boton_iniciar_envio.setBackground(Color.red);
            nuevo_confirmar.setEnabled(false);
        }
    }//GEN-LAST:event_boton_iniciar_envioActionPerformed

    private void About1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_About1ActionPerformed

    }//GEN-LAST:event_About1ActionPerformed

    private void historial_listaValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_historial_listaValueChanged
        TestConnection aux = new TestConnection();
        Vector/*<String>*/ lista_contenidos = aux.obtieneContenidos();
        Vector/*<String>*/ lista_usuarios = aux.obtieneUsuarios();
        Vector/*<String>*/ lista_fechas = aux.obtieneFechas();
        
        int indice = historial_lista.getSelectedIndex();
        String mostrar = (String)lista_contenidos.get(indice);
        fra1 = mostrar;
        String seg ="";
        while(fra1!=""){
            seg = seg +segmentaHistorial(fra1)+"\n";
        }
        String fecha = (String)lista_fechas.get(indice);
        String usuario = (String)lista_usuarios.get(indice);
        String nom = aux.obtieneNombreApellido(usuario);
        historial_contenidomensaje.setText("Creado por: "+nom+"\n"+"Fecha: "+fecha+"\n"+seg);
    }//GEN-LAST:event_historial_listaValueChanged

    private void historial_actualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_historial_actualizarActionPerformed
        TestConnection aux = new TestConnection();
        Vector/*<String>*/ lista_historial = aux.obtieneHistorial(); 
        historial_lista.setListData(lista_historial);
        int n1 = aux.getconexExitosas();
        int n2 = aux.getconexRechazadas();
        historial_exitosas.setText(""+n1);
        historial_rechazadas.setText(""+n2);
        String d1 = aux.getDiaAltaFrecuencia(); 
        String d2 = aux.getDiaBajaFrecuencia();
        historial_diarecibimiento.setText(d1);
        historial_diarechazo.setText(d2);
   
      
    }//GEN-LAST:event_historial_actualizarActionPerformed

    private void About2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_About2ActionPerformed
    }//GEN-LAST:event_About2ActionPerformed

    private void usuarios_actualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usuarios_actualizarActionPerformed
        Tablausuarios tabla=new Tablausuarios();
        TestConnection aux = new TestConnection();
        tabla.addColumn("ID", aux.obtieneID());
        tabla.addColumn("Nick",aux.obtieneNick());
        tabla.addColumn("Dirección",aux.obtieneDireccion());
        tabla.addColumn("Habilitado",aux.obtieneHabilitado());
        tabla.addColumn("Bloqueado",aux.obtieneBloqueado());
        usuarios_lista.setModel(tabla);
    }//GEN-LAST:event_usuarios_actualizarActionPerformed

    private void boton_eliminarMsjeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_eliminarMsjeActionPerformed
        TestConnection aux = new TestConnection();
        Administrador a = Login.admi;
        String usuario = a.getUsuario();
        int indice = historial_lista.getSelectedIndex();
        if(aux.verificaUsuario(indice,usuario)){
            int showConfirmDialog = JOptionPane.showConfirmDialog(null,"¿Está seguro que desea eliminar el mensaje?", "Consulta", JOptionPane.YES_NO_OPTION);
            if(JOptionPane.YES_OPTION == showConfirmDialog){
                if(indice!=-1){
                    aux.eliminaMensaje(indice);
                    historial_contenidomensaje.setText("");
                    Vector/*<String>*/ lista_historial = aux.obtieneHistorial(); 
                    historial_lista.setListData(lista_historial);
                }        
            }
        }else{
            JOptionPane.showMessageDialog(null,"No tiene derecho a borrar este mensaje, porque no fue creado por usted.","Advertencia",JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_boton_eliminarMsjeActionPerformed

    private void usuarios_listaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_usuarios_listaMouseClicked
        filaselec=usuarios_lista.rowAtPoint(evt.getPoint());
        TestConnection aux=new TestConnection();
        boolean bloq=aux.obtieneBloqueadotabla(filaselec);
        if (bloq){
            historial_bloquear.setText("Desbloquear");
        }else{
            historial_bloquear.setText("Bloquear");
        }
    }//GEN-LAST:event_usuarios_listaMouseClicked

    private void historial_bloquearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_historial_bloquearActionPerformed
        TestConnection aux = new TestConnection();
        aux.modificaBloqueado(filaselec);
        if (filaselec!=-1) usuarios_actualizar.doClick();
        historial_bloquear.setText("Bloq/Desbloq");
        filaselec=-1;
    }//GEN-LAST:event_historial_bloquearActionPerformed

    private void About4MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_About4MouseReleased
    }//GEN-LAST:event_About4MouseReleased

    private void About4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_About4ActionPerformed
    }//GEN-LAST:event_About4ActionPerformed

    private void nuevo_contenidoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nuevo_contenidoKeyReleased
        int largo_contenido = (nuevo_contenido.getText()).length();
        if(ClienteOBEX.activar_encabezado){
            int caracteres = 75 - largo_contenido;
            if(caracteres<0){
                contador.setForeground(Color.red);
            }else{
                contador.setForeground(Color.black);
            }
            contador.setText(""+caracteres);
        }else{
            int caracteres = 200 - largo_contenido;
            if(caracteres<0){
                contador.setForeground(Color.red);
            }else{
                contador.setForeground(Color.black);
            }
            contador.setText(""+caracteres);
        }
    }//GEN-LAST:event_nuevo_contenidoKeyReleased

    private TestConnection sql;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton About1;
    private javax.swing.JButton About2;
    private javax.swing.JButton About4;
    private javax.swing.JProgressBar BarraProgreso;
    private javax.swing.JTextArea Encabezado_actual_text;
    public static javax.swing.JLabel Infoenvio;
    public static javax.swing.JLabel Infoenvio2;
    private javax.swing.JButton boton_eliminarMsje;
    public static javax.swing.JButton boton_iniciar_envio;
    private javax.swing.JLabel contador;
    private javax.swing.JLabel encabezadoact_label;
    private javax.swing.JButton historial_actualizar;
    private javax.swing.JButton historial_bloquear;
    private javax.swing.JTextArea historial_contenidomensaje;
    private javax.swing.JLabel historial_diarechazo;
    private javax.swing.JLabel historial_diarecibimiento;
    private javax.swing.JLabel historial_exitosas;
    private javax.swing.JList historial_lista;
    private javax.swing.JLabel historial_rechazadas;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JCheckBox nuevo_activarencabezado;
    private javax.swing.JTextField nuevo_asunto;
    private javax.swing.JButton nuevo_confirmar;
    private javax.swing.JTextArea nuevo_contenido;
    private javax.swing.JButton nuevo_limpiar;
    private javax.swing.JButton usuarios_actualizar;
    private javax.swing.JTable usuarios_lista;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;
}
